﻿Imports System.Data.OleDb

Public Class AddPicture
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub bt_addphoto_Click(sender As Object, e As EventArgs) Handles bt_addphoto.Click
        If file_picture.HasFile Then
            file_picture.SaveAs(Request.MapPath("Pictures") & "/" & file_picture.FileName)
        End If

        Dim conn As OleDbConnection = New OleDbConnection(ConfigurationManager.ConnectionStrings("HauntedLocationString").ConnectionString)
        Dim SqlString As String = "Insert Into AddPicture (Picture, NameOfInvestigator, Description) Values (@f1,@f2,@f3)"
        Dim cmd As OleDbCommand = New OleDbCommand(SqlString, conn)
        cmd.CommandType = CommandType.Text

        conn.Open()

        cmd.Parameters.AddWithValue("@f1", "Pictures/" & file_picture.FileName)
        cmd.Parameters.AddWithValue("@f2", User.Identity.Name)
        cmd.Parameters.AddWithValue("@f3", tb_descript.Text)
        cmd.ExecuteNonQuery()

        conn.Close()

        Response.Redirect("Confirmation.aspx")


    End Sub
End Class